<template>
  <div id="app">
    <h2>测试题</h2>
    <MySubject v-for="(item, index) in arr" :key="index" :obj="item" @sub="item.result = $event"></MySubject>
    <div>
      <MyFlag v-for="(item, index) in arr" :key="index" :obj="item" :index="index"></MyFlag>
    </div>
  </div>
</template>

<script>
import MyFlag from '@/components/Flag'
import MySubject from '@/components/Subject.vue'

export default {
  created() {
    const arr = []
    for (let i = 0; i < 5; i++) {
      const left = Math.floor(Math.random() * 10 + 1)
      const right = Math.floor(Math.random() * 10 + 1)
      arr.push({ left, right, result: null })
    }
    this.arr = arr
  },
  data() {
    return {
      arr: []
    }
  },
  methods: {},
  components: {
    MyFlag,
    MySubject
  },
  computed: {},
  watch: {},

  props: {}
}
</script>

<style>
body {
  background-color: #eee;
}

#app {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>